package com.it.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/*
* 连接池的配置类
* */
@Configuration                          // 配置文件
 @PropertySource("jdbc.properties")      // 引入外部文件
public class DataSourceConfig {
    // @Value("com.mysql.cj.jdbc.Driver")
     @Value("${jdbc.driver}")
    private String driver;

    // @Value("jdbc:mysql://localhost:3306/demo6?serverTimezone=UTC")
     @Value("${jdbc.url}")
    private String url;

    // @Value("root")
     @Value("${jdbc.username}")
    private String username;

    // @Value("123456")
     @Value("${jdbc.passwrod}")
    private String passwrod;



    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driver);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(passwrod);
        return dataSource;
    }
}
